package com.sunb2b.service;

import java.util.List;

import javax.inject.Inject;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Service;

import com.sunb2b.dao.UserDAO;
import com.sunb2b.entity.User;
import com.sunb2b.pojo.PageSearchResult;

@Service
public class UserService {
	@Inject
	private UserDAO userDAO;
	
	public void saveUser(User user){
		userDAO.save(user);
	}
	
	public User getUserById(int id){
		return userDAO.findById(id);
	}
	
	public List<User> getUserByUserName(String userName){
		return userDAO.findByUsername(userName);
	}
	
	public void delete(User user){
		userDAO.delete(user);
	}
	
	public PageSearchResult search(DetachedCriteria dc, int page, int pageSize){
    	return userDAO.search(dc, page, pageSize);
    }
}
